<?php

/**
 * This is the model class for table "tbl_access_points".
 *
 * The followings are the available columns in table 'tbl_access_points':
 * @property string $id
 * @property string $name
 * @property string $location_address
 * @property string $location_gps
 * @property string $ip
 * @property string $subnet1
 * @property string $subnet2
 * @property string $pool1
 * @property string $pool2
 * @property string $tbl_access_points_group_id
 *
 * The followings are the available model relations:
 * @property TblAccessPointsGroup $tblAccessPointsGroup
 */
class AccessPoints extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return AccessPoints the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_access_points';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('tbl_access_points_group_id', 'required'),
			array('name, location_gps', 'length', 'max'=>45),
			array('location_address', 'length', 'max'=>60),
			array('ip', 'length', 'max'=>16),
			array('subnet1, subnet2', 'length', 'max'=>20),
			array('pool1, pool2', 'length', 'max'=>30),
			array('tbl_access_points_group_id', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, name, location_address, location_gps, ip, subnet1, subnet2, pool1, pool2, tbl_access_points_group_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'tblAccessPointsGroup' => array(self::BELONGS_TO, 'TblAccessPointsGroup', 'tbl_access_points_group_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'name' => 'Name',
			'location_address' => 'Location Address',
			'location_gps' => 'Location Gps',
			'ip' => 'Ip',
			'subnet1' => 'Subnet1',
			'subnet2' => 'Subnet2',
			'pool1' => 'Pool1',
			'pool2' => 'Pool2',
			'tbl_access_points_group_id' => 'Tbl Access Points Group',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('location_address',$this->location_address,true);
		$criteria->compare('location_gps',$this->location_gps,true);
		$criteria->compare('ip',$this->ip,true);
		$criteria->compare('subnet1',$this->subnet1,true);
		$criteria->compare('subnet2',$this->subnet2,true);
		$criteria->compare('pool1',$this->pool1,true);
		$criteria->compare('pool2',$this->pool2,true);
		$criteria->compare('tbl_access_points_group_id',$this->tbl_access_points_group_id,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}